﻿using System;
using Ue.Extensions;

namespace Ue.Eagle.ContentManagement.MetaData.Models
{
    public class ContentPartFieldDefinition
    {
        public const string DisplayNameKey = "DisplayName";

        public ContentPartFieldDefinition(string name) 
            : this(new ContentFieldDefinition(null), name, new SettingsDictionary()) { }

        public ContentPartFieldDefinition(
            ContentFieldDefinition contentFieldDefinition, 
            string name, 
            SettingsDictionary settings)
        {
            Name = name;
            FieldDefinition = contentFieldDefinition;
            Settings = settings;
        }

        public string Name { get; private set; }

        public string DisplayName
        {
            get
            {
                return Settings.ContainsKey(DisplayNameKey) 
                    ? Settings[DisplayNameKey] 
                    : Name.CamelFriendly();
            }
            set
            {
                Settings[DisplayNameKey] = value;
            }
        }

        public ContentFieldDefinition FieldDefinition { get; private set; }

        public SettingsDictionary Settings { get; private set; }
    }
}
